<template>
  <!-- 检验规则维护（按工序） -->
  <p-card :bordered="false">


    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <p-form layout="inline" @keyup.enter.native="searchQuery">
        <p-row :gutter="24">
          <p-col :xl="6" :lg="7" :md="8" :sm="24">

            <p-form-model-item label="一级工序名称" prop="processOneId">
              <p-select

                      show-search
                      :value="queryParam.processOneName"
                      placeholder="可输入一级工序模糊搜索"
                      :default-active-first-option="false"
                      :dropdownMatchSelectWidth="false"
                      :show-arrow="false"
                      :filter-option="false"
                      :not-found-content="null"
                      @search="queryAllFirstProcess"
              >
                <div slot="dropdownRender" >
                  <p-table
                          :columns="processTableColumns"
                          :data-source="processOneList"
                          :pagination="false"
                          :customRow="processOneOneSelectChange"
                          bordered
                          :scroll="{ x: 500, y: 300 }"
                  >
                  </p-table>
                </div>

              </p-select>
            </p-form-model-item>

          </p-col>

          <p-col :xl="6" :lg="7" :md="8" :sm="24">
            <p-form-model-item label="二级工序名称" prop="processTwoId">
              <p-select
                      show-search
                      :value="queryParam.processTwoName"
                      placeholder="可输入二级工序模糊搜索"
                      :default-active-first-option="false"
                      :dropdownMatchSelectWidth="false"
                      :show-arrow="false"
                      :filter-option="false"
                      :not-found-content="null"
                      @search="queryAllSecondProcess"
              >
                <div slot="dropdownRender" >
                  <p-table
                          :columns="processTableColumns"
                          :data-source="processTwoList"
                          :pagination="false"
                          :customRow="processTwoTwoSelectChange"
                          bordered
                          :scroll="{ x: 500, y: 300 }"
                  >
                  </p-table>
                </div>
              </p-select>
            </p-form-model-item>
          </p-col>



          <p-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <p-button type="primary" @click="searchQuery" icon="search">查询</p-button>
              <p-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</p-button>
             <!-- <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <p-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>-->
            </span>
          </p-col>

        </p-row>


      </p-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <p-button @click="openAddBtn" type="primary" icon="plus">新增</p-button>



      <template v-if="cgButtonList && cgButtonList.length>0" v-for="(item,index) in cgButtonList">
        <p-button v-if=" item.optType=='js' && (item.groupTag == null || item.groupTag == '' )" :key=" 'cgbtn'+index "
          @click="cgButtonJsHandler(item.buttonCode)" type="primary" :icon="item.buttonIcon">{{ item.buttonName }}
        </p-button>
        <p-button v-else-if=" item.optType=='action' && (item.groupTag == null || item.groupTag == '' )"
          :key=" 'cgbtn'+index " @click="cgButtonActionHandler(item.buttonCode)" type="primary" :icon="item.buttonIcon">
          {{ item.buttonName }}</p-button>
      </template>

      <!-- 高级查询区域 -->
      <j-super-query :fieldList="fieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>

      <p-dropdown v-for="(item,index) in groupTag" :key="index">
        <p-button>
          {{item.name}}
          <p-icon type="down" />
        </p-button>
        <p-menu slot="overlay">
          <template v-for="(items,indexs) in item.data">
            <p-menu-item v-if=" items.optType=='js' " :key="indexs" @click="cgButtonJsHandler(items.buttonCode)">
              <p-icon :type="items.buttonIcon" />{{items.buttonName}}
            </p-menu-item>
            <p-menu-item v-else-if=" items.optType=='action' " :key="indexs"
              @click="cgButtonActionHandler(items.buttonCode)">
              <p-icon :type="items.buttonIcon" />{{items.buttonName}}
            </p-menu-item>
          </template>
        </p-menu>
      </p-dropdown>

      <p-dropdown v-if="selectedRowKeys.length > 0">
        <p-menu slot="overlay">
          <p-menu-item key="1" @click="batchDel">
            <p-icon type="delete" />删除
          </p-menu-item>
        </p-menu>
        <p-button style="margin-left: 8px">
          批量操作
          <p-icon type="down" />
        </p-button>
      </p-dropdown>

    </div>
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
          style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>

        <span style="float:right;">
          <a @click="handleExportXls('首巡检检验规则')">
            <p-icon type="download" />导出</a>
          <p-divider type="vertical" />
          <p-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader"
            :action="importExcelUrl" @change="handleImportExcel">
            <a>
              <p-icon type="import" />导入</a>
          </p-upload>
          <p-divider type="vertical" />
          <a @click="loadData()">
            <p-icon type="sync" />刷新</a>
          <p-divider type="vertical" />
          <p-popover title="自定义列" trigger="click" placement="leftBottom" :overlay-style="getWidth">
            <template slot="content">
              <p-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
                <p-row>
                  <template v-for="(item,index) in defColumns">
                    <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
                      <p-col :span="12">
                        <p-checkbox :value="item.dataIndex">{{ item.title }}</p-checkbox>
                      </p-col>
                    </template>
                  </template>
                </p-row>
              </p-checkbox-group>
            </template>
            <a>
              <p-icon type="setting" />自定义列</a>
          </p-popover>
        </span>
      </div>


      <p-table ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource"
        :pagination="ipagination" :loading="loading"
        :rowSelection="{fixed:true,selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" :scroll="tableScroll"
               :customRow="clickThenSelect"
               :rowClassName="setRowClassName"
        @change="handleTableChange">


        <template slot="isLineleaderConfirm" slot-scope="text, record">
          <f-switch v-model="record.isLineleaderConfirm==1" field="record" :disabled="true" dictCode="" size="small" />
        </template>
        <template slot="isFirstCheck" slot-scope="text, record">
          <f-switch v-model="record.isFirstCheck==1" field="record" :disabled="true" dictCode="" size="small" />
        </template>
        <template slot="isDate" slot-scope="text, record">
          <f-switch v-model="record.isDate==1" field="record" :disabled="true" dictCode="" size="small" />
        </template>
        <template slot="isMcode" slot-scope="text, record">
          <f-switch v-model="record.isMcode==1" field="record" :disabled="true" dictCode="" size="small" />
        </template>
        <template slot="isLinetype" slot-scope="text, record">
          <f-switch v-model="record.isLinetype==1" field="record" :disabled="true" dictCode="" size="small" />
        </template>
        <template slot="isMobillno" slot-scope="text, record">
          <f-switch v-model="record.isMobillno==1" field="record" :disabled="true" dictCode="" size="small" />
        </template>
        <template slot="isMachineTable" slot-scope="text, record">
          <f-switch v-model="record.isMachineTable==1" field="record" :disabled="true" dictCode="" size="small" />
        </template>
        <template slot="isRoundInspect" slot-scope="text, record">
          <f-switch v-model="record.isRoundInspect==1" field="record" :disabled="true" dictCode="" size="small" />
        </template>

        <template slot="rcInspectQty" slot-scope="text, record">
          <div v-if="record.rcInspectMethod==1">{{text}}</div>
        </template>

        <template slot="aqlSimpleStandardName" slot-scope="text, record">
          <div v-if="record.rcInspectMethod==2">{{text}}</div>
        </template>

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="图片不存在"
            style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
          <p-button v-else :ghost="true" type="primary" icon="download" size="small" @click="uploadFile(text)">
            下载
          </p-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="openEditBtn(record)">编辑</a>

          <p-divider type="vertical" />
          <p-dropdown>
            <a class="ant-dropdown-link">更多
              <p-icon type="down" /></a>
            <p-menu slot="overlay">
              <p-menu-item>
                <p-popconfirm title="确定删除吗?" @confirm="() => deleteBtn(record.id)">
                  <a>删除</a>
                </p-popconfirm>
              </p-menu-item>
              <template v-if="cgButtonLinkList && cgButtonLinkList.length>0"
                v-for="(btnItem,btnIndex) in cgButtonLinkList">
                <p-menu-item :key=" 'cgbtnLink'+btnIndex " v-if="showLinkButton(btnItem,record)">
                  <a href="javascript:void(0);" @click="cgButtonLinkHandler(record,btnItem.buttonCode,btnItem.optType)">
                    <p-icon v-if="btnItem.buttonIcon" :type="btnItem.buttonIcon" />
                    {{ btnItem.buttonName }}
                  </a>
                </p-menu-item>
              </template>
            </p-menu>
          </p-dropdown>
        </span>
      </p-table>
    </div>
    <!-- table区域-end -->

    <mesQcFirstroundInspectRule-modal ref="modalForm" :EnhanceJS="EnhanceJS" @ok="modalFormOk">
    </mesQcFirstroundInspectRule-modal>


    <p-modal v-model="pModalVisible" :title="pTitle" :width="900" @ok="pModalOk">
      <p-form-model
              ref="ruleForm"
              :model="form"
              :rules="rules"
              :label-col="labelCol" :wrapper-col="wrapperCol"
      >

        <p-row :gutter="24"  >

          <p-col :span="12" >
            <!--<p-form-model-item label="一级工序" prop="processOneId">
              <p-select v-model="form.processOneId" placeholder="请选择规则类型" showSearch @change="processOneSelectChange">
                <p-select-option
                        v-for="(item,index) in processOneList"
                        :key="index"
                        :value="item.id+'-'+item.processmname"
                >{{item.processmname}}</p-select-option>
              </p-select>
            </p-form-model-item>-->


            <p-form-model-item label="一级工序" prop="processOneId">
              <p-select
                      show-search
                      :value="form.processOneName"
                      placeholder="可输入一级工序模糊搜索"
                      :default-active-first-option="false"
                      :dropdownMatchSelectWidth="false"
                      :show-arrow="false"
                      :filter-option="false"
                      :not-found-content="null"
                      @search="queryAllFirstProcess"
              >
                <div slot="dropdownRender" >
                  <p-table
                          :columns="processTableColumns"
                          :data-source="processOneList"
                          :pagination="false"
                          :customRow="processOneSelectChange"
                          bordered
                          :scroll="{ x: 500, y: 300 }"
                  >
                  </p-table>
                </div>

              </p-select>
            </p-form-model-item>
          </p-col>

          <p-col :span="12">
            <p-form-model-item label="一级工序编码" prop="processOneCode">
              <p-input v-model="form.processOneCode" disabled>

              </p-input>
            </p-form-model-item>
          </p-col>


          <p-col :span="12">
            <p-form-model-item label="二级工序" prop="processTwoId">
              <!--<p-select v-model="form.processTwoId" placeholder="请选择规则类型" showSearch @change="processTwoSelectChange">
                <p-select-option
                        v-for="(item,index) in processTwoList"
                        :key="index"
                        :value="item.id+'-'+item.processmname"
                >{{item.processmname}}</p-select-option>
              </p-select>-->

              <p-select
                      show-search
                      :value="form.processTwoName"
                      placeholder="可输入二级工序模糊搜索"
                      :default-active-first-option="false"
                      :dropdownMatchSelectWidth="false"
                      :show-arrow="false"
                      :filter-option="false"
                      :not-found-content="null"
                      @search="queryAllSecondProcess"
              >
                <div slot="dropdownRender" >
                  <p-table
                          :columns="processTableColumns"
                          :data-source="processTwoList"
                          :pagination="false"
                          :customRow="processTwoSelectChange"
                          bordered
                          :scroll="{ x: 500, y: 300 }"
                  >
                  </p-table>
                </div>

              </p-select>


            </p-form-model-item>

          </p-col>


          <p-col :span="12">
            <p-form-model-item label="二级工序编码" prop="processTwoCode">
              <p-input v-model="form.processTwoCode" disabled>

              </p-input>
            </p-form-model-item>

          </p-col>

          <p-col :span="12">
            <p-form-model-item label="首检" prop="isFirstCheck">
              <p-radio-group v-model="form.isFirstCheck" @change="isFirstCheckRidaoChange">
                <p-radio :value="1">
                  是
                </p-radio>
                <p-radio :value="2">
                  否
                </p-radio>
              </p-radio-group>
            </p-form-model-item>

          </p-col>

          <p-col :span="12">
            <p-form-model-item label="巡检" prop="isRoundInspect">
              <p-radio-group v-model="form.isRoundInspect" @change="isRoundInspectRadioChange">
                <p-radio :value="1">
                  是
                </p-radio>
                <p-radio :value="2">
                  否
                </p-radio>
              </p-radio-group>
            </p-form-model-item>

          </p-col>

          <p-col :span="12">
            <p-form-model-item label="是否线长确认" prop="isLineleaderConfirm">
              <p-radio-group v-model="form.isLineleaderConfirm" :disabled="form.isFirstCheck==2">
                <p-radio :value="1">
                  是
                </p-radio>
                <p-radio :value="2">
                  否
                </p-radio>
              </p-radio-group>
            </p-form-model-item>

          </p-col>

          <p-col :span="12">
            <p-form-model-item label="触发巡检方式" prop="roundInspectMethod">
              <p-select v-model="form.roundInspectMethod" placeholder="请选择触发巡检方式" @change="roundInspectMethodChange" :disabled="this.form.isRoundInspect==2">
                <p-select-option
                        v-for="(item,index) in roundInspectMethodList"
                        :key="index"
                        :value="item.value"
                >{{item.title}}</p-select-option>
              </p-select>
            </p-form-model-item>

          </p-col>

          <p-col :span="12">
            <p-form-model-item label="日期" prop="isDate">
              <p-radio-group v-model="form.isDate" :disabled="form.isFirstCheck==2">
                <p-radio :value="1">
                  是
                </p-radio>
                <p-radio :value="2">
                  否
                </p-radio>
              </p-radio-group>
            </p-form-model-item>

          </p-col>

          <p-col :span="12">
            <p-form-model-item label="巡检频次" prop="roundInspectFrequency">
              <p-input  addon-after="小时/次" v-model="form.roundInspectFrequency" :min="1" :disabled="this.form.isRoundInspect==2" type="number"  v-if="form.roundInspectMethod==1" @change="numberChange"/>


              <p-input-group compact v-if="form.roundInspectMethod==2">
                <p-input   v-model="form.rifLeft" type="number" style="width:80px" :min="1" @change="numberChange2" :disabled="this.form.isRoundInspect==2"/>
                <p-input
                        style=" width: 30px;  pointer-events: none;"
                        placeholder=":"
                        disabled
                />
                <p-input   v-model="form.rifRight" type="number" style="width:80px;" :min="1" @change="numberChange3" :disabled="this.form.isRoundInspect==2"/>
              </p-input-group>

            </p-form-model-item>

          </p-col>

          <p-col :span="12">
            <p-form-model-item label="品号" prop="isMcode">
              <p-radio-group v-model="form.isMcode" :disabled="form.isFirstCheck==2">
                <p-radio :value="1">
                  是
                </p-radio>
                <p-radio :value="2">
                  否
                </p-radio>
              </p-radio-group>
            </p-form-model-item>

          </p-col>

          <p-col :span="12">
            <p-form-model-item label="巡检时间段" prop="roundInspectTimequantum">


              <p-time-picker style="width:100px;"
                             :disabled="this.form.isRoundInspect==2"
                             v-model="form.startTime"
                             :allowClear="false"
                             @change="(val,dateStrings)=>changeTime(val,dateStrings,'startTime')"
                             format="HH:mm"/>
              -

              <p-time-picker style="width:100px;"
                             :disabled="this.form.isRoundInspect==2"
                             :disabledHours="getDisabledHours"
                             :disabledMinutes="getDisabledMinutes"
                             :allowClear="false"
                             :disabledSeconds="getDisabledSeconds"
                             v-model="form.endTime"
                             @change="(val,dateStrings)=>changeTime(val,dateStrings,'endTime')"
                             format="HH:mm" />

            </p-form-model-item>
          </p-col>

          <p-col :span="12">
            <p-form-model-item label="线别" prop="isLinetype">
              <p-radio-group v-model="form.isLinetype" :disabled="form.isFirstCheck==2">
                <p-radio :value="1">
                  是
                </p-radio>
                <p-radio :value="2">
                  否
                </p-radio>
              </p-radio-group>
            </p-form-model-item>

          </p-col>

          <p-col :span="12">

            <p-form-model-item label="巡检抽样方式" prop="rcInspectMethod">
              <p-select v-model="form.rcInspectMethod" placeholder="请选择巡检方式" :disabled="form.isRoundInspect==2" @change="rcInspectMethodChange">
                <p-select-option
                        v-for="(item,index) in rcInspectMethodList"
                        :key="index"
                        :value="item.value"
                >{{item.title}}</p-select-option>
              </p-select>

            </p-form-model-item>


          </p-col>


          <p-col :span="12">
            <p-form-model-item label="工单" prop="isMobillno">
              <p-radio-group v-model="form.isMobillno" :disabled="form.isFirstCheck==2">
                <p-radio :value="1">
                  是
                </p-radio>
                <p-radio :value="2">
                  否
                </p-radio>
              </p-radio-group>
            </p-form-model-item>

          </p-col>

          <p-col :span="12" v-if="form.rcInspectMethod==1">
            <p-form-model-item label="巡检抽检数量（PCS）" prop="rcInspectQty" :label-col="labelCol1" :wrapper-col="wrapperCol1" >
              <p-input   v-model="form.rcInspectQty" type="number" :disabled="form.isRoundInspect==2" style="width:200px;margin-left: 20px" @change="rcInspectQtyChange"/>
            </p-form-model-item>
          </p-col>

          <p-col :span="12" v-else-if="form.rcInspectMethod==2">

            <p-form-model-item label="AQL抽量标准" prop="aqlSimpleStandardName">
              <p-select v-model="form.aqlSimpleStandardName" showSearch :disabled="form.isRoundInspect==2" >
                <p-select-option
                        v-for="(item,index) in aqlNameList"
                        :key="index"
                        :value="item"
                >{{item}}</p-select-option>
              </p-select>

            </p-form-model-item>


          </p-col>
          <p-col :span="12" v-else>
            <p-form-model-item label="AQL抽量标准" prop="aqlSimpleStandardName">
              <p-select v-model="form.a" showSearch :disabled="true" >
                <p-select-option
                        v-for="(item,index) in aqlNameList"
                        :key="index"
                        :value="item"
                >{{item}}</p-select-option>
              </p-select>

            </p-form-model-item>
          </p-col>




          <p-col :span="12">
            <p-form-model-item label="机台" prop="isMachineTable">
              <p-radio-group v-model="form.isMachineTable" :disabled="form.isFirstCheck==2">
                <p-radio :value="1">
                  是
                </p-radio>
                <p-radio :value="2">
                  否
                </p-radio>
              </p-radio-group>
            </p-form-model-item>

          </p-col>


        </p-row>



      </p-form-model>
    </p-modal>


    <!-- 弹出窗 -->
    <Fx-compontens-modal @ok="modalFormOk" ref="modalCompon" :getList="queryInfo" :title="title"
      :dictOptions="dictOptions"></Fx-compontens-modal>
  </p-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { api } from '@/api/manage'
  import JSuperQuery from '@/components/jeecg/JSuperQuery.vue'
  import { filterObj } from '@/utils/util';
  import MesQcFirstroundInspectRuleModal from './modules/MesQcFirstroundInspectRuleModal'

  import Vue from 'vue'
  import moment from 'moment'
  import { initDictOptions, filterMultiDictText } from '@/components/dict/JDictSelectUtil'
  import ButtonExpHandler from '@/components/jeecgbiz/modules/ButtonExpHandler'
  import { postAction, getAction, deleteAction,putAction } from '@/api/manage'
  import FxCompontensModal from "@/components/jeecgbiz/FxCompontensModal"



  //高级查询modal需要参数
  const superQueryFieldList = [

    {
      value: 'isFirstCheck',
      text: '是否首检',
      type: 'string',
      dictCode: 'mes_is_use'
    },
    {
      value: 'isLineleaderConfirm',
      text: '是否线长确认',
      type: 'string',
      dictCode: 'mes_is_use'
    },

    {
      value: 'isDate',
      text: '日期',
      type: 'string',
      dictCode: 'mes_is_use'
    },
    {
      value: 'isMcode',
      text: '品号',
      type: 'string',
      dictCode: 'mes_is_use'
    },
    {
      value: 'isLinetype',
      text: '线别',
      type: 'string',
      dictCode: 'mes_is_use'
    },
    {
      value: 'isMobillno',
      text: '工单',
      type: 'string',
      dictCode: 'mes_is_use'
    },
    {
      value: 'isMachineTable',
      text: '机台',
      type: 'string',
      dictCode: 'mes_is_use'
    },
    {
      value: 'isRoundInspect',
      text: '是否巡检',
      type: 'string',
      dictCode: 'mes_is_use'
    },
    {
      value: 'roundInspectMethod',
      text: '触发巡检方式',
      type: 'select',
      dictCode: 'round_inspect_method'
    },
    {
      value: 'roundInspectFrequency',
      text: '巡检频率（小时/次）',
      type: 'int'
    },
    {
      value: 'roundInspectTimequantum',
      text: '巡检时间段',
      type: 'String'
    },
    {
      value: 'rcInspectMethod',
      text: '巡检抽样方式',
      type: 'select',
      dictCode: 'rc_inspect_method'
    },
    {
      value: 'rcInspectQty',
      text: '巡检抽样数量',
      type: 'string'
    },
    {
      value: 'aqlSimpleStandardName',
      text: 'AQL抽样标准',
      type: 'string'
    },
    {
      value: 'createBy',
      text: '创建人',
      type: 'string'
    },
    {
      value: 'createTime',
      text: '创建日期',
      type: 'Date'
    },
    {
      value: 'updateBy',
      text: '更新人',
      type: 'string'
    },
    {
      value: 'updateTime',
      text: '更新日期',
      type: 'Date'
    },
    {
      value: 'remark',
      text: '备注',
      type: 'string'
    },
  ]

  export default {
    name: "MesQcFirstroundInspectRuleList",
    mixins: [JeecgListMixin],
    components: {
      JSuperQuery,
      FxCompontensModal,
      MesQcFirstroundInspectRuleModal
    },
    data() {
      return {
        fieldList: superQueryFieldList,
        superQueryFlag: false,
        superQueryParams: '',
        description: '首巡检检验规则管理页面',
        cgButtonLinkList: [],
        title: '',//存表名
        EnhanceJS: '',
        cgButtonList: [],
        groupTag: [],
        queryInfo: [],
        code: '',

        editP:{},
        rowId:0,

        pModalVisible:false,
        pTitle:'',
        labelCol: { span: 6 },
        wrapperCol: { span: 16 },

        labelCol1: { span: 9 },
        wrapperCol1: { span: 13 },

        processOneList:[],
        processOneMap:[],


        processTwoListFirst:[],
        processTwoMapFirst:[],
        processTwoList:[],
        processTwoMap:[],


        roundInspectMethodList:[],
        rcInspectMethodList:[],

        processTableColumns:[
          {
            title: '工序名称',
            align: 'center',
            dataIndex: 'processmname',
          },
          {
            title: '工序编码',
            align: 'center',
            dataIndex: 'processmcode',
          }
        ],
        form: {
          processOneId:'',
          processOneCode:'',
          processOneName:'',
          processTwoId:'',
          processTwoCode:'',
          processTwoName:'',
          isFirstCheck:2,
          isLineleaderConfirm:2,
          isDate:2,
          isMcode:2,
          isLinetype:2,
          isMobillno:2,
          isMachineTable:2,
          isRoundInspect:2,
          roundInspectMethod:'',
          roundInspectFrequency:1,
          rifLeft:1,
          rifRight:1,
          roundInspectTimequantum:'',
          startTime: moment('08:00', 'HH:mm'),
          endTime: moment('17:00', 'HH:mm'),
          rcInspectMethod:'',
          rcInspectQty:'',
          aqlSimpleStandardName:'',
        },

        currentState:1,

        rules: {
          processOneId: [{ required: true, message: '请选择一级工序', trigger: 'change' }],
          processOneCode: [{ required: false, message: '请输入一级编码', trigger: 'change' }],
          processTwoId: [{ required: true, message: '请选择二级工序', trigger: 'change' }],
          processTwoCode: [{ required: false, message: '请输入二级编码', trigger: 'change' }],
/*          roundInspectMethod: [{ required: true, message: '请选择巡检方式', trigger: 'change' }],*/
/*          roundInspectFrequency: [{ required: true, message: '请选择巡检频次', trigger: 'change' }],*/
          startTime: [{ required: true, message: '请选择巡检时间段', trigger: 'change' }],
          endTime: [{ required: true, message: '请选择巡检时间段', trigger: 'change' }],
/*          rcInspectMethod: [{ required: true, message: '请选择巡检抽检方式', trigger: 'change' }],*/
          rcInspectQty: [{ required: false, message: '请输入巡检抽样数量', trigger: 'change' }],


        },
        aqlNameList:[],

        // 表头
        columns: [
        ],
        //列设置
        settingColumns: [],
        //列定义
        defColumns: [
          {
            title: "序号",
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '一级工序名称',
            align: 'center',
            dataIndex: 'processOneName',
          },
          {
            title: '一级工序编码',
            align: 'center',
            dataIndex: 'processOneCode',
          },
          {
            title: '二级工序名称',
            align: 'center',
            dataIndex: 'processTwoName',
          },
          {
            title: '二级工序编码',
            align: 'center',
            dataIndex: 'processTwoCode',
          },
          {
            title: '是否首检',
            align: 'center',
            dataIndex: 'isFirstCheck_dictText',
            scopedSlots: { customRender: 'isFirstCheck' },
          },
          {
            title: '是否线长确认',
            align: 'center',
            dataIndex: 'isLineleaderConfirm_dictText',
            scopedSlots: { customRender: 'isLineleaderConfirm' },
          },

          {
            title:'首检触发配置条件',
            children:[


              {
                title: '日期',
                align: 'center',
                dataIndex: 'isDate_dictText',
                scopedSlots: { customRender: 'isDate' },
              },
              {
                title: '品号',
                align: 'center',
                dataIndex: 'isMcode_dictText',
                scopedSlots: { customRender: 'isMcode' },
              },
              {
                title: '线别',
                align: 'center',
                dataIndex: 'isLinetype_dictText',
                scopedSlots: { customRender: 'isLinetype' },
              },
              {
                title: '工单',
                align: 'center',
                dataIndex: 'isMobillno_dictText',
                scopedSlots: { customRender: 'isMobillno' },
              },
              {
                title: '机台',
                align: 'center',
                dataIndex: 'isMachineTable_dictText',
                scopedSlots: { customRender: 'isMachineTable' },
              },
            ],
          },

          {
            title: '是否巡检',
            align: 'center',
            dataIndex: 'isRoundInspect_dictText',
            scopedSlots: { customRender: 'isRoundInspect' },
          },
          {
            title: '触发巡检方式',
            align: 'center',
            dataIndex: 'roundInspectMethod_dictText',
          },
          {
            title: '巡检频率（小时/次）',
            align: 'center',
            dataIndex: 'roundInspectFrequency',
          },
          {
            title: '巡检时间段',
            align: 'center',
            dataIndex: 'roundInspectTimequantum',
          },
          {
            title: '巡检抽样方式',
            align: 'center',
            dataIndex: 'rcInspectMethod_dictText',
          },
          {
            title: '巡检抽样数量',
            align: 'center',
            dataIndex: 'rcInspectQty',
            scopedSlots: { customRender: 'rcInspectQty' },
          },

          {
            title: 'AQL抽样标准',
            align: 'center',
            dataIndex: 'aqlSimpleStandardName',
            scopedSlots: { customRender: 'aqlSimpleStandardName' },
          },
          {
            title: '创建人',
            align: 'center',
            dataIndex: 'createBy',
          },
          {
            title: '创建日期',
            align: 'center',
            dataIndex: 'createTime',
          },
          {
            title: '更新人',
            align: 'center',
            dataIndex: 'updateBy',
          },
          {
            title: '更新日期',
            align: 'center',
            dataIndex: 'updateTime',
          },
          {
            title: '备注',
            align: 'center',
            dataIndex: 'remark',
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            width: 147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: '/mes-quality/mesQcFirstroundInspectRule/list',
          delete: '/mes-quality/mesQcFirstroundInspectRule/delete',
          deleteBatch: '/mes-quality/mesQcFirstroundInspectRule/deleteBatch',
          exportXlsUrl: '/mes-quality/mesQcFirstroundInspectRule/exportXls',
          importExcelUrl: '/mes-quality/mesQcFirstroundInspectRule/importExcel',
          getColumns: '/mes-quality/online/cgform/api/getColumns/',
          buttonAction: '/mes-quality/online/cgform/api/doButton',
        },
        dictOptions: {},
      }
    },
    computed: {
      importExcelUrl: function () {
        return `${api.test}${this.url.importExcelUrl}`;
      },
      getWidth: function () {
        if (this.defColumns.length > 14) {
          return { width: '500px' }
        }
      },
      tableScroll: function () {
        if (this.columns.length > 13) {
          return { x: this.columns.length * 150 - 450 }
        }
      }
    },
    created() {
      this.initAqlNameList();
      this.initRcInspectMethodList();
      this.initRoundInspectMethodList();
      this.initProcessONETWO('');
      this.initButtonList();
      this.initColumns();
    },

    methods: {

      clickThenSelect(record) {
        return {
          on: {
            click: () => {
              if(record.id){
                this.rowId = record.id;
                //this.onSelectChange(record.id.split(","), [record]);
              }

            },
          },
        };
      },
      setRowClassName(record){
        return record.id === this.rowId ? 'clickRowStyl' : '';
      },


      //封装listToMap
      listToMap(list,name){
        let map = {};
        for(let i in list){
          map[list[i][name]] = list[i];
        }
        return map;
      },

      initRoundInspectMethodList(){
        getAction('/basic-business/sys/dict/queryDictItemsByCode',{dictCode:'round_inspect_method'}).then(res=>{
          if(res.success){
            this.roundInspectMethodList = res.data;
          }
        })
      },

      initAqlNameList(){
        getAction('/mes-quality/mesQcAqlSampleStandard/queryAqlName').then(res=>{
          if(res.success){
            this.aqlNameList = res.data;
          }
        })
      },

      initRcInspectMethodList(){
        getAction('/basic-business/sys/dict/queryDictItemsByCode',{dictCode:'rc_inspect_method'}).then(res=>{
          if(res.success){
            this.rcInspectMethodList = res.data;
          }
        })
      },



      deleteBtn(id){
        deleteAction('/mes-quality/mesQcFirstroundInspectRule/delete/'+id).then(res=>{
          if(res.success){
            this.loadData();
            this.$message.success("删除成功!")
          }else{
            this.$message.warning("删除失败!")
          }
        })
      },

      initProcessONETWO(keyword){
        getAction('/mes-craft/craft/mesPeDefinition/getAllFirstDef?keyword='+keyword).then(res=>{
          if(res.success){
            this.processOneList = res.data;
            this.processOneMap = this.listToMap(this.processOneList,'id');
          }
        })
      },

      queryAllFirstProcess(value){
        this.initProcessONETWO(value)
      },





      openAddBtn(){
        this.pModalVisible = true;
        this.pTitle = '新增';
        this.currentState=1;
        this.$refs['ruleForm'].resetFields();
        this.formDataReset();
      },



      openEditBtn(record){

        if(this.$refs['ruleForm']){
          this.$refs['ruleForm'].resetFields();
        }

        this.pModalVisible = true;
        this.pTitle = '编辑';
        this.currentState=2;
        this.editP = record;

        let data = record;
        this.form  = {
          processOneId:data.processOneId,
          processOneCode:data.processOneCode,
          processOneName:data.processOneName,
          processTwoId:data.processTwoId,
          processTwoCode:data.processTwoCode,
          processTwoName:data.processTwoName,
          isFirstCheck:data.isFirstCheck,
          isLineleaderConfirm:data.isLineleaderConfirm,
          isDate:data.isDate,
          isMcode:data.isMcode,
          isLinetype:data.isLinetype,
          isMobillno:data.isMobillno,
          isMachineTable:data.isMachineTable,
          isRoundInspect:data.isRoundInspect,
          roundInspectMethod:data.roundInspectMethod+'',
          roundInspectFrequency:data.roundInspectFrequency,
          roundInspectTimequantum:data.roundInspectTimequantum,
          rcInspectMethod:data.rcInspectMethod+'',
          rcInspectQty:data.rcInspectQty,
          aqlSimpleStandardName:data.aqlSimpleStandardName,
        };


        this.queryProcessTwoListByOneCode(data.processOneCode);


        if(data.roundInspectMethod==2){
          Vue.set( this.form,'rifLeft',parseInt(data.roundInspectFrequency.split(':')[0]));
          Vue.set( this.form,'rifRight',parseInt(data.roundInspectFrequency.split(':')[1]));

        }

        Vue.set(this.form,'startTime',moment(this.form.roundInspectTimequantum.split('-')[0], 'HH:mm'));
        Vue.set(this.form,'endTime',moment(this.form.roundInspectTimequantum.split('-')[1], 'HH:mm'));


      },


      pModalOk(){
       let flag = true;

       if(this.form.startTime._i==''){
         flag = false;
         this.$message.error("请选择巡检时间段开始时间");
       }

        if(this.form.endTime._i==''){
          flag = false;
          this.$message.error("请选择巡检时间段结束时间");
        }

        if(this.form.rcInspectMethod==1){
          if(this.form.rcInspectQty==''){
            flag = false;
            this.$message.error("请输入巡检抽样数量（PCS）");
          }
        }else if(this.form.rcInspectMethod==2){
          if(this.form.aqlSimpleStandardName==''){
            flag = false;
            this.$message.error("请选择AQL抽样标准");
          }
        }

        if(flag){

          this.form.roundInspectTimequantum = this.form.startTime._i+'-'+this.form.endTime._i;

          this.$refs.ruleForm.validate(valid => {
            if (valid) {
             if(this.currentState==1){
               this.pAddOperation();
             }else if(this.currentState==2){
               this.pEidOperation();
             }
            } else {
              console.log('error submit!!');
              return false;
            }
          });
        }
      },

      formDataReset(){
        this.form={
                  processOneId:'',
                  processOneCode:'',
                  processOneName:'',
                  processTwoId:'',
                  processTwoCode:'',
                  processTwoName:'',
                  isFirstCheck:2,
                  isLineleaderConfirm:2,
                  isDate:2,
                  isMcode:2,
                  isLinetype:2,
                  isMobillno:2,
                  isMachineTable:2,
                  isRoundInspect:2,
                  roundInspectMethod:'',
                  roundInspectFrequency:1,
                  rifLeft:1,
                  rifRight:1,
                  roundInspectTimequantum:'',
                  startTime: moment('08:00', 'HH:mm'),
                  endTime: moment('17:00', 'HH:mm'),
                  rcInspectMethod:'',
                  rcInspectQty:''
        }


      },
      isFirstCheckRidaoChange(){
        if(this.form.isFirstCheck==2){
          Vue.set(this.form,'isLineleaderConfirm',2);
          Vue.set(this.form,'isDate',2);
          Vue.set(this.form,'isMcode',2);
          Vue.set(this.form,'isLinetype',2);
          Vue.set(this.form,'isMobillno',2);
          Vue.set(this.form,'isMachineTable',2);

        }else if(this.form.isFirstCheck==1){
          Vue.set(this.form,'isLineleaderConfirm',1);
          Vue.set(this.form,'isDate',1);
          Vue.set(this.form,'isMcode',1);
          Vue.set(this.form,'isLinetype',1);

        }
      },

      isRoundInspectRadioChange(){
        if(this.form.isRoundInspect==2){
          Vue.set(this.form,'roundInspectMethod','');
          Vue.set(this.form,'roundInspectFrequency','');
          Vue.set(this.form,'rifLeft','');
          Vue.set(this.form,'rifRight','');
          Vue.set(this.form,'roundInspectTimequantum','');
          Vue.set(this.form,'startTime', moment('08:00', 'HH:mm'));
          Vue.set(this.form,'endTime',moment('17:00', 'HH:mm'));
          Vue.set(this.form,'rcInspectMethod','');
          Vue.set(this.form,'rcInspectQty','');

        }else if(this.form.isRoundInspect==1){
          Vue.set(this.form,'roundInspectMethod','1');
          Vue.set(this.form,'roundInspectFrequency',1);
          Vue.set(this.form,'rifLeft',1);
          Vue.set(this.form,'rifRight',1);
          Vue.set(this.form,'roundInspectTimequantum','');
          Vue.set(this.form,'startTime', moment('08:00', 'HH:mm'));
          Vue.set(this.form,'endTime',moment('17:00', 'HH:mm'));
          Vue.set(this.form,'rcInspectMethod','1');
          Vue.set(this.form,'rcInspectQty',1);

        }
      },

      formDataConvert(){
        let data = this.form;

        let result = {
          processOneId:data.processOneId,
          processTwoId:data.processTwoId,
          processOneCode:data.processOneCode,
          processTwoCode:data.processTwoCode,
          processOneName:data.processOneName,
          processTwoName:data.processTwoName,
          isFirstCheck:data.isFirstCheck,
          isLineleaderConfirm:data.isLineleaderConfirm,
          isDate:data.isDate,
          isMcode:data.isMcode,
          isLinetype:data.isLinetype,
          isMobillno:data.isMobillno,
          isMachineTable:data.isMachineTable,
          isRoundInspect:data.isRoundInspect,
          roundInspectMethod:data.roundInspectMethod,
          roundInspectFrequency:data.roundInspectFrequency,
          roundInspectTimequantum:data.roundInspectTimequantum,
          rcInspectMethod:data.rcInspectMethod,
          rcInspectQty:data.rcInspectQty,
          aqlSimpleStandardName:data.aqlSimpleStandardName
        };

        console.log(data.aqlSimpleStandardName)
        console.log(result.aqlSimpleStandardName)

        if(data.roundInspectMethod==2){
          result.roundInspectFrequency = data.rifLeft+':'+data.rifRight;
        }



        return result;
      },

      rcInspectMethodChange(){
        Vue.set(this.form,'rcInspectQty','');
        Vue.set(this.form,'aqlSimpleStandardName','');
      },
      pAddOperation(){

        let data = this.formDataConvert();
        postAction('/mes-quality/mesQcFirstroundInspectRule/add',data).then(res=>{
          if(res.success){
            this.pModalVisible = false;
            this.$message.success("新增成功！");
            this.formDataReset();
            this.loadData();
          }else{
            this.$message.warning(res.msg);
          }
        })
      },

      pEidOperation(){
        let data = this.formDataConvert();
        let result = this.editP;
        result.processOneId = data.processOneId;
        result.processTwoId = data.processTwoId;
        result.processOneCode=data.processOneCode;
        result.processTwoCode=data.processTwoCode;
        result.processOneName = data.processOneName;
        result.processTwoName = data.processTwoName;
        result.isFirstCheck=data.isFirstCheck;
        result.isLineleaderConfirm=data.isLineleaderConfirm;
        result.isDate=data.isDate;
        result.isMcode=data.isMcode;
        result.isLinetype=data.isLinetype;
        result.isMobillno=data.isMobillno;
        result.isMachineTable=data.isMachineTable;
        result.isRoundInspect=data.isRoundInspect;
        result.roundInspectMethod=data.roundInspectMethod;
        result.roundInspectFrequency=data.roundInspectFrequency;
        result.roundInspectTimequantum=data.roundInspectTimequantum;
        result.rcInspectMethod=data.rcInspectMethod;
        result.rcInspectQty=data.rcInspectQty;
        result.aqlSimpleStandardName=data.aqlSimpleStandardName;


        putAction('/mes-quality/mesQcFirstroundInspectRule/edit',result).then(res=>{
          if(res.success){
            this.pModalVisible = false;
            this.$message.success("修改成功！");
            this.formDataReset();
            this.loadData();
          }else{
            this.$message.warning(res.msg);
            this.loadData();
          }
        })
      },


      processOneSelectChange(record){


        return {
          on: {
            click: () => {
              this.form.processTwoId='';
              this.form.processTwoCode='';
              this.form.processTwoName='';

              this.form.processOneId = record.id;
              this.form.processOneCode =record.processmcode;
              this.form.processOneName =record.processmname;



              this.queryProcessTwoListByOneCode(record.processmcode);
            },
          },
        };
      },




      processOneOneSelectChange(record){


        return {
          on: {
            click: () => {

              Vue.set(this.queryParam,'processTwoId','');
              Vue.set(this.queryParam,'processTwoCode','');
              Vue.set(this.queryParam,'processTwoName','');
              Vue.set(this.queryParam,'processOneId',record.id);
              Vue.set(this.queryParam,'processOneCode',record.processmcode);
              Vue.set(this.queryParam,'processOneName',record.processmname);
            /*  this.queryParam.processTwoId='';
              this.queryParam.processTwoCode='';
              this.queryParam.processTwoName='';

              this.queryParam.processOneId = record.id;
              this.queryParam.processOneCode =record.processmcode;
              this.queryParam.processOneName =record.processmname;*/

              this.queryProcessTwoListByOneCode(record.processmcode);
            },
          },
        };
      },



      queryAllSecondProcess(value){
        let resultList = [];

        this.processTwoListFirst.forEach(item=>{
          let flag = false;
          if(item.processmcode.indexOf(value)!=-1){
            flag  = true;
          }
          if(item.processmname.indexOf(value)!=-1){
            flag  = true;
          }

          if(flag){
            resultList.push(item);
          }
        })

        this.processTwoList = resultList;
        this.processTwoMap =  this.listToMap(this.processTwoList,'id');
      },

      queryProcessTwoListByOneCode(firstProcessCode){
        getAction('/mes-craft/craft/mesPeDefinition/getAllUnderFirstDef?firstProcessCode='+firstProcessCode).then(res=>{
          if(res.success){
            this.processTwoList = res.data;

            this.processTwoList.forEach(item=>{
              delete item.children;
            })
            this.processTwoMap = this.listToMap(this.processTwoList,'id');

            this.processTwoListFirst = this.processTwoList;
            this.processTwoMapFirst = this.processTwoMap;
          }else{
            this.$message.warning(res.msg);
          }
        })
      },


      processTwoSelectChange(record){
        return {
          on: {
            click: () => {
              this.form.processTwoId=record.id;
              this.form.processTwoCode=record.processmcode;
              this.form.processTwoName=record.processmname;
            },
          },
        };
      },
      processTwoTwoSelectChange(record){
        return {
          on: {
            click: () => {
              Vue.set( this.queryParam,'processTwoId',record.id);
              Vue.set( this.queryParam,'processTwoCode',record.processmcode);
              Vue.set( this.queryParam,'processTwoName',record.processmname);
             /* this.queryParam.processTwoId=record.id;
              this.queryParam.processTwoCode=record.processmcode;
              this.queryParam.processTwoName=record.processmname;*/
            },
          },
        };
      },

      roundInspectMethodChange(){
        if(this.form.roundInspectMethod==1){
          Vue.set(this.form,'roundInspectFrequency',1);

        }else if(this.form.roundInspectMethod==2){
          Vue.set(this.form,'rifLeft',1);
          Vue.set(this.form,'rifRight',1);
        }
      },


      convertStringToId(str){
        if(!str){
          return 0;
        }

        return parseInt(str.split('-')[0]);

      },


      numberChange(value){
        if(this.form.roundInspectFrequency==''||this.form.roundInspectFrequency<1){
          this.form.roundInspectFrequency=1
        }

      },
      numberChange2(value){
        console.log(value)
        console.log(this.form.rifLeft)
        if(this.form.rifLeft==''||this.form.rifLeft<1){
          Vue.set(this.form,'rifLeft',1);
        }
        Vue.set(this.form,'rifLeft',parseInt(this.form.rifLeft));


      },
      rcInspectQtyChange(){
        if(this.form.rcInspectQty==''||this.form.rcInspectQty<1){
          Vue.set(this.form,'rcInspectQty',1);
        }
        Vue.set(this.form,'rcInspectQty',parseInt(this.form.rcInspectQty));
      },
      numberChange3(value){
        if(this.form.rifRight==''||this.form.rifRight<1){
          Vue.set(this.form,'rifRight',1);
        }

        Vue.set(this.form,'rifRight',parseInt(this.form.rifRight));
      },

      moment,
      changeTime (val, dateStrings, type) {
        if (type === 'startTime') {
          this.form.startTime = moment(dateStrings, 'HH:mm')
        } else {
          this.form.endTime = moment(dateStrings, 'HH:mm')
        }
      },
      getDisabledHours () {
        let hours = []
        let time = this.form.startTime._i
        let timeArr = time.split(':')
        for (var i = 0; i < parseInt(timeArr[0]); i++) {
          hours.push(i)
        }
        return hours
      },
      getDisabledMinutes (selectedHour) {
        let time = this.form.startTime._i
        let timeArr = time.split(':')
        let minutes = []
        if (selectedHour == parseInt(timeArr[0])) {
          for(var i = 0; i < parseInt(timeArr[1]); i++) {
            minutes.push(i)
          }
        }
        return minutes
      },
      getDisabledSeconds (selectedHour, selectedMinute) {
        let time = this.form.startTime._i
        let timeArr = time.split(':')
        let second = []
        if (selectedHour == parseInt(timeArr[0]) && selectedMinute == parseInt(timeArr[1])) {
          for(var i = 0; i <= parseInt(timeArr[2]); i++) {
            second.push(i)
          }
        }
        return second
      },






      isFirstCheckChange(value){
          this.form.isFirstCheck = value?1:2;
      },
      isLineleaderConfirmChange(value){
        this.form.isLineleaderConfirmChange = value?1:2;
      },
      isDateChange(value){
        this.form.isDate = value?1:2;
      },
      isMcodeChange(value){
        this.form.isMcode = value?1:2;
      },
      isLinetypeChange(value){
        this.form.isLinetype = value?1:2;
      },
      isMobillnoChange(value){
        this.form.isMobillno = value?1:2;
      },
      isMachineTableChange(value){
        this.form.isMachineTable = value?1:2;
      },
      isRoundInspectChange(value){
        this.form.isRoundInspect = value?1:2;
      },

      initColumns() {
        //权限过滤（列权限控制时打开，修改第二个参数为授权码前缀）
        //this.defColumns = colAuthFilter(this.defColumns,'testdemo:');

        var key = this.$route.name + ":colsettings";
        let colSettings = Vue.ls.get(key);
        if (colSettings == null || colSettings == undefined) {
          let allSettingColumns = [];
          this.defColumns.forEach(function (item, i, array) {
            allSettingColumns.push(item.dataIndex);
          })
          this.settingColumns = allSettingColumns;
          this.columns = this.defColumns;
        } else {
          this.settingColumns = colSettings;
          const cols = this.defColumns.filter(item => {
            if (item.key == 'rowIndex' || item.dataIndex == 'action') {
              return true;
            }
            if (colSettings.includes(item.dataIndex)) {
              return true;
            }
            return false;
          })
          this.columns = cols;
        }
      },
      //列设置更改事件
      onColSettingsChange(checkedValues) {
        var key = this.$route.name + ":colsettings";
        Vue.ls.set(key, checkedValues, 7 * 24 * 60 * 60 * 1000)
        this.settingColumns = checkedValues;
        const cols = this.defColumns.filter(item => {
          if (item.key == 'rowIndex' || item.dataIndex == 'action') {
            return true
          }
          if (this.settingColumns.includes(item.dataIndex)) {
            return true
          }
          return false
        })
        this.columns = cols;
      },

      //高级查询方法
      handleSuperQuery(arg) {
        if (!arg) {
          this.superQueryParams = ''
          this.superQueryFlag = false
        } else {
          this.superQueryFlag = true
          this.superQueryParams = JSON.stringify(arg)
        }
        this.loadData()
      },
      // 获取查询条件
      getQueryParams() {
        let sqp = {}
        if (this.superQueryParams) {
          sqp['superQueryParams'] = encodeURI(this.superQueryParams)
        }
        var param = Object.assign(sqp, this.queryParam, this.isorter);
        param.field = this.getQueryField();
        param.pageNo = this.ipagination.current;
        param.limit = this.ipagination.pageSize;
        return filterObj(param);
      },
      initDictConfig() {
      },

      // 弹出窗组件
      showDemoModal() {
        this.$refs.modalCompon.modalShow();
      },
      // 点击btn获取数据
      btnGetData(tableName, title) {
        getAction(`${this.url.getColumns}`, {
          tableName: tableName
        }).then(
          res => {
            if (res.code == 0) {
              this.queryInfo = res.data.columns
              this.title = title
              this.dictOptions = res.data.dictOptions
              this.showDemoModal()
            } else {
              this.$message.warning(res.msg);
            }
          }
        )
      },

      //筛选分组
      getGroupTag(arrList) {
        let arr = [];
        var map = {},
          dest = [];
        arrList.forEach((item, index) => {
          if (item.groupTag) {
            arr.push(item);
          }
        });
        for (var i = 0; i < arr.length; i++) {
          var ai = arr[i];
          if (!map[ai.groupTag]) {
            dest.push({
              groupTag: ai.groupTag,
              name: ai.groupName,
              data: [ai]
            });
            map[ai.groupTag] = ai;
          } else {
            for (var j = 0; j < dest.length; j++) {
              var dj = dest[j];
              if (dj.groupTag == ai.groupTag) {
                dj.data.push(ai);
                break;
              }
            }
          }
        }
        this.groupTag = dest
        console.log(dest);
      },
      showLinkButton(item, record) {
        let btn = new ButtonExpHandler(item.exp, record);
        return btn.show;
      },
      initButtonList() {
        getAction(`${this.url.getColumns}3b5e4f63505740a1afe3e7f7287292dd`).then((res) => {
          console.log("--获取自定义按钮->>", res);
          if (res.success) {
            this.code = res.data.code;
            this.initCgButtonList(res.data.cgButtonList);
            this.initCgEnhanceJs(res.data.enhanceJs);
            this.getGroupTag(res.data.cgButtonList);
          } else {
            this.$message.warning(res.msg)
          }
        })
      },
      initCgEnhanceJs(enhanceJs) {
        //console.log("--onlineList-js增强",enhanceJs)
        if (enhanceJs) {
          let Obj = eval("(" + enhanceJs + ")");
          this.EnhanceJS = new Obj(getAction, postAction, deleteAction);
          this.cgButtonJsHandler('created')
        } else {
          this.EnhanceJS = ''
        }
      },
      initCgButtonList(btnList) {
        let linkArr = []
        let buttonArr = []
        if (btnList && btnList.length > 0) {
          for (let i = 0; i < btnList.length; i++) {
            let temp = btnList[i]
            if (temp.buttonStyle == 'button') {
              buttonArr.push(temp)
            } else if (temp.buttonStyle == 'link') {
              linkArr.push(temp)
            }
          }
        }
        this.cgButtonLinkList = [...linkArr]
        this.cgButtonList = [...buttonArr]
        console.log("链接增强", this.cgButtonLinkList);
      },
      cgButtonJsHandler(buttonCode) {
        if (this.EnhanceJS[buttonCode]) {
          this.EnhanceJS[buttonCode](this)
        }
      },
      cgButtonActionHandler(buttonCode) {
        //处理自定义button的 需要配置该button自定义sql
        if (!this.selectedRowKeys || this.selectedRowKeys.length == 0) {
          this.$message.warning("请先选中一条记录")
          return false
        }
        if (this.selectedRowKeys.length > 1) {
          this.$message.warning("请只选中一条记录")
          return false
        }
        let params = {
          formId: this.code,
          buttonCode: buttonCode,
          dataId: this.selectedRowKeys[0]
        }
        console.log("自定义按钮请求后台参数：", params)
        postAction(this.url.buttonAction, params).then(res => {
          if (res.success) {
            this.loadData()
            this.$message.success("处理完成!")
          } else {
            this.$message.warning("处理失败!")
          }
        })

      },
      cgButtonLinkHandler(record, buttonCode, optType) {
        if (optType == "js") {
          if (this.EnhanceJS[buttonCode]) {
            this.EnhanceJS[buttonCode](this, record)
          }
        } else if (optType == "action") {
          let params = {
            formId: this.code,
            buttonCode: buttonCode,
            dataId: record.id
          }
          console.log("自定义按钮link请求后台参数：", params)
          postAction(this.url.buttonAction, params).then(res => {
            if (res.success) {
              this.loadData()
              this.$message.success("处理完成!")
            } else {
              this.$message.warning("处理失败!")
            }
          })
        }
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
  /deep/.clickRowStyl td{
    background:#00b4ed !important;
  }

  /deep/.ant-table-tbody.clickRowStyl:hover>td {
    background-color:#00b4ed
  }
</style>